{% extends "base_mobile.html" %}

{% block title %}
CMAT 21 - Events
{% endblock title %}

{% block heading %}
  Events
{% endblock heading %}

{% block event_li %}class="ui-btn-active"{% endblock %}

{% block subtitle %}
{% if not event_code %}
{% else %}
  {% if not level %}
  {% else %}
    {% if not age_group %}
      {{level_name}}
    {% else %}
      {{level_name}} - {{age_group_name}}
    {% endif %}
  {% endif %}
{% endif %}
{% endblock subtitle %}

{% block content %}
<ul data-role="listview"><li data-role="list-divider">
{% if not event_code %}
  Select event
{% else %}
  {% if not level %}
    Select level
  {% else %}
    {% if not age_group %}
      Select age group
    {% else %}
      Select gender
    {% endif %}
  {% endif %}
{% endif %}
</li>
{% if not event_code %}
  {% for event_type, meta in events %}
    <li><a href="/events/{{event_type.code}}">
      <p>{{event_type.name}}</p>
      <p class="ui-li-count">{{meta.num_competitors}}</p>
    </a></li>
  {% endfor %}
{% else %}{% if not level %}
  {% for level, meta in levels %}
    <li><a href="/events/{{event_code}}/{{level.code}}">
      {{level.name}}
      <p class="ui-li-count">{{meta.num_competitors}}</p>
    </a></li>
  {% endfor %}
{% else %}{% if not age_group %}
  {% for age_group, meta in age_groups %}
    <li><a href="/events/{{event_code}}/{{level}}/{{age_group.code}}">
      {{age_group.name}}
      <p class="ui-li-count">{{meta.num_competitors}}</p>
    </a></li>
  {% endfor %}
{% else %}
  {% for gender, meta in genders %}
    <li><a href="/event/{{level}}{{gender.code}}{{age_group}}{{event_code}}/">
      {{gender.name}}
      <p class="ui-li-count">{{meta.num_competitors}}</p>
    </a></li>
  {% endfor %}
{% endif %}{% endif %}{% endif %}
</ul>
{% endblock content %}
